#!/bin/bash
#created by douyu
#judging the status of 80 alived;
mail=0000@163.com
while :;
do
  if ! `netstat -lntp |grep ':80 ' |grep -q 'LISTEN'`;
  then
      /usr/local/apache2/bin/apachectl restart 2&>/dev/null
      python /root/SHELL100/customsh/mail.py $mail "mail title" "mail content"
  fi
  n=`ps aux |grep httpd |grep -cv grep`
  if [ "$n" -eq 0 ];
  then
      /usr/local/apache2/bin/apachectl start 2>/tmp/apache_starterror
      python /root/SHELL100/customsh/mail.py $mail "mail title" "`cat /tmp/apache_starterror`"
  fi
  sleep 30
done
